﻿using System.Collections.Generic;
using DBConnection.ConnectionClass;
using DBConnection.Helper;

namespace DBConnection
{
    public class ConnectionDB
    {
        public ConnectionType Type { get; set; }
        readonly ClassDefinition _aDefinition=new ClassDefinition();
        private BaseConnection aConnection;
        public ConnectionDB()
        {
            _aDefinition.SetConnection();
        }
        public ConnectionDB(ConnectionType aType)
        {
            _aDefinition.SetConnection(aType);
            switch (ClassDefinition.contp)
            {
                case 1001:aConnection=new OleDataBaseConnection();break;
                case 1002:aConnection=new MySqlDataBaseConnection();break;
                case 1003:aConnection=new MsSqlDataBaseConnection();break;
                case 1004:aConnection=new OdbcDataBaseConnection();break;
                case 1005:aConnection=new OracleDataBaseConnection();break;
                case 1006:aConnection=new PostgreSqlDataBaseConnection();break;
            }
        }
        public ConnectionDB(ConnectionType aType,string aConnectionString)
        {
            _aDefinition.SetConnection(aType);
            switch (ClassDefinition.contp)
            {
                case 1001: aConnection = new OleDataBaseConnection(aConnectionString); break;
                case 1002: aConnection = new MySqlDataBaseConnection(aConnectionString); break;
                case 1003: aConnection = new MsSqlDataBaseConnection(aConnectionString); break;
                case 1004: aConnection = new OdbcDataBaseConnection(aConnectionString); break;
                case 1005: aConnection = new OracleDataBaseConnection(aConnectionString); break;
                case 1006: aConnection = new PostgreSqlDataBaseConnection(aConnectionString); break;
            }
        }
        public void SetConnectionString(string connectionstring)
        {
            aConnection.ConnectionString = connectionstring;
        }

        public List<string>[] Select(Table aTable)
        {
            List<string>[] t=aConnection.Select(aTable);
            return t;
        }
        public List<string> Select(Table aTable,Column aColumn)
        {
            List<string> t = aConnection.Select(aTable,aColumn);
            return t;
        }
        public List<string> Select(Table aTable,params Column[] aColumn)
        {
            foreach (var column in aColumn)
            {
                List<string>[] t = aConnection.Select(aTable, aColumn);
            }
            return t;
        }
        
    }
}
